<?php

namespace app\store\validate;

use think\Validate;

class ArticleValidate extends Validate
{
    protected $rule = [
        'sort' => 'require|>=:0',
        'article_title' => 'require|max:100',
        'content' => 'require',
        'view_count' => 'require|>=:0',
        'content' => 'require',
        'status' => 'require|in:0,1'
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'sort.require' => '排序不能为空',
        'article_title.require' => '文章标题不能为空!',
        'view_count.require' => '阅读数不能为空!',
        'content.require' => '文章内容不能为空!',
        'status.in' => '无效的状态值!',
    ];


    public function sceneSwitch()
    {
        return $this->only(['id','status'])
                    ->append('id', 'require|integer');
    }

    public function sceneEdit()
    {
    	return $this->only(['id','sort','article_title','content','view_count','status'])
                    ->append('id', 'require|integer');
            
    }   
}